package com.xgit.iov.work.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xgit.iov.common.core.service.impl.SuperServiceImpl;
import com.xgit.iov.work.mapper.DbdTerminalMapper;
import com.xgit.iov.work.model.DbdTerminal;
import com.xgit.iov.work.service.IDbdTerminalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 终端Service业务层处理
 *
 * @author william
 * @date 2020-12-04
 */

@Service
public class DbdTerminalServiceImpl extends SuperServiceImpl<DbdTerminalMapper, DbdTerminal> implements IDbdTerminalService {

    @Autowired
    private DbdTerminalMapper dbdTerminalMapper;

    /**
     * 查询终端
     *
     * @param id 终端ID
     * @return 终端
     */
    @Override
    public DbdTerminal selectDbdTerminalById(Long id) {
        return dbdTerminalMapper.selectDbdTerminalById(id);
    }

    /**
     * 查询终端列表
     *
     * @param dbdTerminal 终端
     * @return 终端
     */
    @Override
    public IPage selectDbdTerminalPage(Page page, DbdTerminal dbdTerminal) {
        dataRuleFilter(dbdTerminal);
        return dbdTerminalMapper.selectDbdTerminalPage(page,dbdTerminal);
    }

    /**
     * 新增终端
     *
     * @param dbdTerminal 终端
     * @return 结果
     */
    @Transactional
    @Override
    public int insertDbdTerminal(DbdTerminal dbdTerminal) {
        return dbdTerminalMapper.insert(dbdTerminal);
    }

    /**
     * 修改终端
     *
     * @param dbdTerminal 终端
     * @return 结果
     */
    @Transactional
    @Override
    public int updateDbdTerminal(DbdTerminal dbdTerminal) {
        return dbdTerminalMapper.updateById(dbdTerminal);
    }

    /**
     * 批量删除终端
     *
     * @param ids 需要删除的终端ID
     * @return 结果
     */
    @Transactional
    @Override
    public int deleteDbdTerminalByIds(Long[] ids) {
        return dbdTerminalMapper.deleteBatchIds(CollUtil.toList(ids));
    }

}
